import varCss from "admin/styles/variables.scss";
import Vue from "vue";

Vue.mixin({
    data() {
        return {
            var: varCss,
            imgUrl: "https://image.huizhouyunhai.com", //图片url
            isDev: process.env.NODE_ENV === 'development',
            // 日期组件快捷设置
            scPickerOptions: {
                shortcuts: [
                    {
                        text: "最近一周",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit("pick", [start, end]);
                        },
                    },
                    {
                        text: "最近一个月",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit("pick", [start, end]);
                        },
                    },
                    {
                        text: "最近三个月",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit("pick", [start, end]);
                        },
                    },
                ],
            },
        };
    },
    computed: {
        //角色列表
        roles() {
            return this.$store.getters.roles;
        },
        // 当前学校
        currSchool() {
            return this.$store.state.team.currTeam;
        },

        // 页面名称
        pageName() {
            return this.$route.fullPath.split('/')[this.$route.fullPath.split('/').length - 1] + '_';
        },
        // 权限按钮
        btns() {
            return this.$store.getters.btns;
        },
        // 保存
        isSave() {
            return this.btns.includes(`${this.pageName}save`)
        },
        // 添加
        isAdd() {
            return this.btns.includes(`${this.pageName}add`)
        },
        // 编辑
        isEdit() {
            return this.btns.includes(`${this.pageName}edit`)
        },
        // 查看
        isView() {
            return this.btns.includes(`${this.pageName}view`)
        },
        // 删除
        isDel() {
            return this.btns.includes(`${this.pageName}del`)
        },
        // 同步
        isSync() {
            return this.btns.includes(`${this.pageName}sync`)
        },
        // 导入
        isImport() {
            return this.btns.includes(`${this.pageName}import`)
        },
        // 导出
        isExport() {
            return this.btns.includes(`${this.pageName}export`)
        },
        // 家长列表
        isParent() {
            return this.btns.includes(`${this.pageName}parent`)
        },
        // 海康授权
        isHikAuthor() {
            return this.btns.includes(`${this.pageName}hik_author`)
        },
        // 发送通知
        isSendNotice() {
            return this.btns.includes(`${this.pageName}send_notice`)
        },
        // 添加家长
        isAddParents() {
            return this.btns.includes(`${this.pageName}add_parents`)
        },
        // 恢复
        isRestore() {
            return this.btns.includes(`${this.pageName}restore`)
        },
        // 退款
        isRefund() {
            return this.btns.includes(`${this.pageName}refund`)
        },

    },
    methods: {
        // 根据学校名称获取id
        getSchoolId(name) {
            return this.$store.state.team.teams.find((v) => v.schoolName === name).id;
        },
        // 根据id获取学校名称
        getSchoolName(id) {
            return this.$store.state.team.teams.find((v) => v.id === id).schoolName;
        },
    },
});
